/**
 * 动态往DOM中添加内容
 * 回调
 */

 const posts=[
     {title:"Post one",body:"this is post one"},
     {title:"Post two",body:"this is post two"}
 ];

 function getPosts(){
     setTimeout(()=>{
         let output='';
         posts.forEach(post=>{
             output+=`<li>${post.title}</li>`
         });
         document.body.innerHTML=output;
     },1000)
 }

 getPosts(); 

 function createdPost(post,callback){
     setTimeout(()=>{
         posts.push(post);
         callback();
        //  console.log(posts);
     },2000)
 }

 createdPost({title:"Post three",body:"this is post three"},getPosts)
